package com.snake.springboot.custom.service.port.adapter.listener;


import com.snake.springboot.custom.api.model.bill.BillEnum;
import com.snake.springboot.custom.api.service.goods.CustStryGoodsService;
import com.snake.springboot.custom.dao.mybatis.entity.bill.BillDO;
import com.snake.springboot.custom.service.port.adapter.event.BillRetEvent;
import com.snake.springboot.custom.service.port.adapter.event.BillUccCallbackEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * <p>账单内部回调事件
 * 类{@code BillUccCallbackListener} </br>
 * 创建时间2025/4/6 15:23
 * @author yangxt
 * @see
 */
@Component
public class BillInnerListener {
    @Autowired
    private CustStryGoodsService goodsService;

    @EventListener
    public void callbcak(BillUccCallbackEvent event){
        BillDO data = event.getData();
        if (BillEnum.BillType.STRATEGY_PAY.getCode().equals(data.getBillType())){
            goodsService.callback(data.getBillId());
            return;
        }
        if (BillEnum.BillType.POINTS_PAY.getCode().equals(data.getBillType())){
            return;
        }
    }

    @EventListener
    public void ret(BillRetEvent event){
        BillDO data = event.getData();
        if (BillEnum.BillType.STRATEGY_PAY.getCode().equals(data.getBillType())){
            goodsService.ret(data.getBillId());
            return;
        }

    }
}
